#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false); // 关闭IO同步
	cin.tie(nullptr), cout.tie(nullptr);

	istringstream iss{string{istreambuf_iterator<char>{cin},
							 istreambuf_iterator<char>{}}}; // 将输入一次全部读入输入缓冲区
	string token;
	unordered_map<string, int> map;

	// 按空格分割字符串
	while (iss >> token)
	{
		map[token]++;
	}

	auto cmp = [](const pair<string, int> &kv1, const pair<string, int> &kv2)
	{
		if (kv1.second != kv2.second)
		{
			return kv1.second < kv2.second;
		}
		else
		{
			return kv1.first > kv2.first;
		}
	};

	priority_queue<pair<string, int>, vector<pair<string, int>>, decltype(cmp)> pq(cmp);
	for (auto &kv : map)
	{
		if (kv.second >= 3)
		{
			pq.push(kv);
		}
	}
	while (!pq.empty())
	{
		cout << pq.top().first << endl;
		pq.pop();
	}

	return 0;
}
// 64 位输出请用 printf("%lld")